package com.ruoyi.web.controller.applet;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.BdmTopupRecord;
import com.ruoyi.system.domain.dto.BdmTopupRecordDto;
import com.ruoyi.system.service.IBdmTopupRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 小程序提现Controller
 *
 * @author ruoyi
 * @date 2024-12-20
 */
@RestController
@RequestMapping("/applet/record")
public class AppletTopupRecordController extends BaseController
{
    @Autowired
    private IBdmTopupRecordService bdmTopupRecordService;

    /**
     * 小程序我的余额提现
     */
    @Log(title = "小程序我的余额提现", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult appletAdd(@Valid @RequestBody BdmTopupRecordDto bdmTopupRecordDto)
    {
        bdmTopupRecordDto.setType("2");
        bdmTopupRecordDto.setWay("1");
        return toAjax(bdmTopupRecordService.insertBdmTopupRecord(bdmTopupRecordDto));
    }

    // 提现统计

    /**
     * 提现统计
     * 1. 本周提现  2.本月提现  3.累计提现
     *
     * @return
     */
    @GetMapping("/statistics")
    public AjaxResult statistics(){
        return success(bdmTopupRecordService.statistics());
    }

    /**
     * 提现列表
     * @param bdmTopupRecord
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(BdmTopupRecord bdmTopupRecord)
    {
        startPage();
        bdmTopupRecord.setSysUserid(SecurityUtils.getUserId());
        List<BdmTopupRecord> list = bdmTopupRecordService.selectBdmTopupRecordList(bdmTopupRecord);
        return getDataTable(list);
    }

    @GetMapping("/pclist")
    public TableDataInfo pclist(BdmTopupRecord bdmTopupRecord)
    {
        startPage();
        List<BdmTopupRecord> list = bdmTopupRecordService.selectBdmTopupRecordList(bdmTopupRecord);
        return getDataTable(list);
    }
}
